package com.codergd.gra.dao;

import com.codergd.gra.bean.Com;
import com.codergd.gra.bean.User;
import com.codergd.gra.config.PageQuery;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface ComDao {
    @Select("select password from com where iphone = #{iphone}")
    public String selectCom(String iphone);

    @Select("select state from com where iphone = #{iphone}")
    public int selectCom3(String iphone);

    //根据企业名称查找
    @Select("select * from com where comname = #{comname}")
    public List<Com> selectCom1(String comname);

    @Insert("insert into com(comname,iphone,password,address,manage,introduce,state,image)"
            + "values (#{comname},#{iphone},#{password},#{address},#{manage},#{introduce},#{state},#{image})")
    public int insertCom(Com com);

    //根据手机号查找id
    @Select("select id from com where iphone = #{iphone}")
    public int selectId(String iphone);

    //根据id查找企业信息
    @Select("select * from com where id = #{id}")
    public List<Com> selectComById(int id);

    @Select("select * from com")
    public List<Com> selectCom2();

    //修改企业状态
    @Update("update com set state = #{state} where id = #{id}")
    public int updateState(int id,int state);

    //修改企业状态
    @Update("update com set iphone = #{iphone},comname = #{comname}, " +
            "password = #{password},address = #{address},manage = #{manage}," +
            "introduce = #{introduce} where id = #{id}")
    public int updateCom(int id,String iphone,String comname,String password,String address,String manage,String introduce);

    @Select("select id,name,iphone,image,resume,work,city,content from users " +
            "where name like concat('%',{name},'%')" )
    Page<User> pageQuery(PageQuery pageQuery);
}
